<?php

class MainController extends Controller {

	public function actionIndex() {
		$criteria=new CDbCriteria();
		$criteria->condition='status=:status';
		$criteria->params=array(':status'=>News::STATUS_PUBLIC);
		$criteria->order='date';
		$criteria->limit=10;

		$news=News::model()->findAll($criteria);

		$content=Pages::model()->findBypk(1);

		if($content===null){
			throw new CHttpException(404,'The requested page does not exist.');
		}

		$this->render('index',array('news'=>$news,'content'=>$content));
	}

}